package com.cn.intelligence.controller;

import com.cn.intelligence.pojo.EUDataGridResult;
import com.cn.intelligence.pojo.TaotaoResult;
import com.cn.intelligence.pojo.TbItemParam;
import com.cn.intelligence.service.ItemParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by Administrator on 2017/4/21.
 */
@Controller
public class ItemParamController {
    @Autowired
    ItemParamService itemParamService ;

    /**
     * 查询规格参数列表
     * @param page
     * @param rows
     * @return
     */
    @RequestMapping("/item/param/list")
    @ResponseBody
    public EUDataGridResult getItemParamList(Integer page,Integer rows){
        EUDataGridResult euDataGridResult=  itemParamService.getItemParamList(page,rows);
        return euDataGridResult;
    }
    @RequestMapping("/item/param/query/itemcatid/{itemCatId}")
    @ResponseBody
    public TaotaoResult queryItemByItemCatId(@PathVariable long itemCatId){
        TaotaoResult taotaoResult = itemParamService.getItemParamByItemCatId(itemCatId);
        return taotaoResult;

    }
    @RequestMapping(value="/item/param/save/{cid}",method = RequestMethod.POST)
    @ResponseBody
    public TaotaoResult saveItemParam(@PathVariable long cid,String paramData){
       TbItemParam itemParam = new TbItemParam();
       itemParam.setItemCatId(cid);
       itemParam.setParamData(paramData);
        return itemParamService.saveItemParam(itemParam);
    }
    @RequestMapping(value="/item/param/delete",method = RequestMethod.POST)
    @ResponseBody
    public TaotaoResult deleteItemParam( Long ids[]){
        return itemParamService.deleteItemParam(ids);
    }
    @RequestMapping(value="/item/param/item/query",method = RequestMethod.GET)
    @ResponseBody
    public TaotaoResult queryItemParamItem(Long itemId){
        return itemParamService.getItemParamItemByItemId(itemId);
    }

}
